Import mojo
Import tween2
Import diddy
Import model


Class Player Extends Sprite
	Field tweenX:Tween2
	Field tweenY:Tween2
	
	Method New()
		Super.New(game.images.Find("mapstrip"), 0,0)
		frame = 3
		hitBoxHeight=50
					hitBoxWidth=50
					hitBoxY=25
					hitBoxX=25
	End Method


	Method OnUpdate:Void() 
		If(tweenX <> null)
			tweenX.Update()	
			tweenY.Update()
			x = tweenX.Value()
			y = tweenY.Value()
			
			Move()
		EndIf
	End

	Method Draw:Void(offsetx:Float = 0, offsety:Float = 0, rounded:Bool = false)	
		If Self.alpha > 1 Then Self.alpha = 1
		If Self.alpha < 0 Then Self.alpha = 0
		SetAlpha Self.alpha
		SetColor red, green, blue ' doesnt work with images!?!??!
		if rounded
			DrawImage(image.image, int(x - offsetx), int(y - offsety), rotation, scaleX, scaleY, frame)
		else
			DrawImage(image.image, x - offsetx, y - offsety, rotation, scaleX, scaleY, frame)
		endif
		SetColor 255, 255, 255
		SetAlpha 1
	End
	
	Method isMoving:Bool()
	If(tweenX <> null)
		Return tweenX.isActive
	Endif
	End
		
	Method Stop:Void()
		tweenX.Stop()
		tweenY.Stop()
	End
	
	Method MoveTo(destX:Float, destY:Float, duration:Float)
	Print "player moving to"+destX+ " "+destY
		tweenX = New Tween2(Tween2.Cubic.EaseInOut,x,destX,duration)
		tweenY = New Tween2(Tween2.Cubic.EaseInOut,y,destY,duration)
		tweenX.Start()
		tweenY.Start()
	End
End










